export default {
	namespaced: true,
	state: () => ({
		adress_obj: JSON.parse(uni.getStorageSync('adress_obj') || "{}"),
		token: uni.getStorageSync('token') || '',
		userinfo: JSON.parse(uni.getStorageSync('userinfo') || '{}'),
		un_login_go_login_history: {}
	}),
	actions: {
		
	},
	mutations: {
		set_adress(state, obj) {
			state.adress_obj = obj
			this.commit('m_user/set_adress_to_storage');
		},
		
		// 更新用户信息
		set_userinfo(state, userinfo) {
			state.userinfo = userinfo;
			this.commit('m_user/set_userinfo_to_storage');
		},
		
		// 获取设置token
		set_token(state, token) {
			state.token = token
			this.commit('m_user/set_token_to_storage');
		},
		
		set_un_login_go_login_history(state, obj) {
			state.un_login_go_login_history = obj
		},
		
		// 持久储存
		set_token_to_storage(state) {
			uni.setStorageSync('token', state.token)
		},
		set_userinfo_to_storage(state) {
			uni.setStorageSync('userinfo', JSON.stringify(state.userinfo))
		},
		set_adress_to_storage(state) {
			uni.setStorageSync('adress_obj', JSON.stringify(state.adress_obj))
		}
	},
	getters: {
		adress_str(state) {
			// 返回详细地址
			return state.adress_obj.provinceName + state.adress_obj.cityName + state.adress_obj.countyName + state.adress_obj.detailInfo;
		}
	}
	
}